<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>

<html>
	<head>
		<title>商品详情</title>
		<meta name="decorator" content="default"/>
		<script type="text/javascript" src="${ctxStatic }/js/hidden_nav.js"></script>
		<script type="text/javascript" src="${ctxStatic }/js/jquery.imagezoom.min.js"></script>
		<script type="text/javascript" src="${ctxStatic }/js/xiangqing.js"></script>
		<script type="text/javascript">
			$(function(){
				// 商品类别load
				var url_cate = "${ctx}/procatelist?urltype=pul";
				$("#procate").load(url_cate);
				
				var pid=parseInt($("#prod").val());
				var num=parseInt($(".Ytxt").val());
				calcPrice(pid, num);
				$(".Ydel").on("click", function(){
					var o = $(this).next();
					var n = parseInt(o.val());
					if(n>1){
						o.val(n-1);
						var prodid = parseInt($("#prod").val());
						calcPrice(prodid, o.val());
					}
				});
				
				$(".Yadd").on("click", function(){
					var o = $(this).prev();
					var n = parseInt(o.val());					
					o.val(n+1);	
					var prodid = parseInt($("#prod").val());
					calcPrice(prodid, o.val());
				});
				
				$(".Ytxt").numeral();
				
				$(".Ytxt").on("blur keyup", function(){
					var prodid = parseInt($("#prod").val());
					calcPrice(prodid, $(this).val());
				})
				
				$(".bybuy").on("click", function(){
					var prodid = parseInt($("#prod").val());
					var num = parseInt($(".Ytxt").val());
					addToCart(prodid, num);
				})
				
				
			})
			
			/*
			* 动态获取计算价格
			*/			
			function calcPrice(id, num){
				$.post("${ctx}/getprice",
					{"id":id, "num": num},
					function(price){
						$("#price").text(price);
					}
				);
			}
			
			/*
			   添加到购物车 
			 */
			function addToCart(id, num){				
				$.post("${ctx}/addtocart",
					   {"id":id, "num": num},
					   function(message){//返回值为提示信息						   
					   	  if (message == '9998'){//session失效
					   	  	  window.location="${ctx}/login";
					   	  }					   
					   	$.jBox.messager('添加到购物车成功', '购物车');
					   }
				);				
			}
		</script>
	</head>
<body>
<div class="nav_hidden">
	<div class="nav_center">
    	<div class="headnav">
        	<span>全部药品分类</span>
            <p></p>
            <div class="nav_hid" style=" display:none;" id="procate">
                <!-- 药品分类下拉 -->
            </div>
        </div>
        <div class="headtitle">
        	<h2 class="headnav01">所有类目</h2>
            >
            <h3 class="headnav02">${categoryPath}</h3>            
        </div>
    </div>
</div> 
<div class="wrap_detail clearfix">
	<div class="sideleft">
        <div class="box">       
        <c:if test="${not empty prod.pics}">
        <c:set value="${fn:split(prod.pics, '|')}" var="pic" />        
			<div class="tb-booth tb-pic tb-s310">				
				<a href="javascript:;"><img src="${svr_url}${pic[0]}" alt="${prod.proName}" rel="${svr_url}${pic[0]}" class="jqzoom" /></a>
			</div>
			<ul class="tb-thumb" id="thumblist">				
				<c:forEach items="${pic }" var="p" varStatus="st">
					<li <c:if test="${st.index == '0' }">class="tb-selected"</c:if>>
						<div class="tb-pic tb-s40">
							<a href="javascript:;">
								<img src="${svr_url}${p}" mid="${svr_url}${p}" big="${svr_url}${p}" style="width:40px;height:40px;">
							</a>
						</div>
					</li>
				</c:forEach>				
			</ul>
			</c:if>
		<c:if test="${empty prod.pics}">
			<div class="tb-booth tb-pic tb-s310">				
				<a href="javascript:;"><img src="${ctxStatic }/images/defaultprod.jpg" alt="该商品暂无图片信息" rel="${ctxStatic }/images/defaultprod.jpg" class="jqzoom" /></a>
			</div>
			<ul class="tb-thumb" id="thumblist">
				<li class="tb-selected">
					<div class="tb-pic tb-s40">
						<a href="javascript:;">
							<img src="${ctxStatic }/images/defaultprod.jpg" mid="${ctxStatic }/images/defaultprod.jpg" big="${ctxStatic }/images/defaultprod.jpg" style="width:40px;height:40px;">
						</a>
					</div>
				</li>
			</ul>
		</c:if>
		</div>		
    </div>
    
    <div class="sideright">
    	<div class="prodes_t clearfix">
        	<h2>${prod.proName}&nbsp;</h2>
            <div class="promo">
            	<span>会员价：</span>
                <strong class="yb_price">
                	<em class="yb_rmb">￥</em>
                    <em class="price_num" id="price">0.0</em>
                </strong>
            </div>
        </div>
        <div class="Ydrug_info clearfix">
        	<dl>
            	<dt>剂型：</dt>
                <dd>${prod.dosageForm }&nbsp;</dd>
            </dl>
            <dl>
            	<dt>单位：</dt>
                <dd>${prod.unit }&nbsp;</dd>
            </dl>
            <dl>
            	<dt>产地：</dt>
                <dd>${prod.place }&nbsp;</dd>
            </dl>
            <dl>
            	<dt>通用编码：</dt>
                <dd>${prod.commonCode }&nbsp;</dd>
            </dl>
            <dl>
            	<dt>通用名称：</dt>
                <dd>${prod.commonName}&nbsp;</dd>
            </dl>
            <dl>
            	<dt>批准文号：</dt>
                <dd>${prod.auditingFileNo}&nbsp;</dd>
            </dl>
            <dl>
            	<dt>质量标准：</dt>
                <dd>${prod.qualityStandard}&nbsp;</dd>
            </dl>
        </div>
        <div class="Ypro_dl clearfix">
        	<dl>
            	<dt>规格</dt>
                <dd>${prod.etalon }</dd>
            </dl>
            <dl>
            	<dt>数量</dt>
                <dd>
                	<div class="Yp_r5c">
                    	<input class="Ydel" type="button"/>
                        <input class="Ytxt" type="text" value="1"/>
                        <input class="Yadd" type="button"/>
                        <input type="hidden" id="prod" value=${prod.id }/>
                    </div>
                </dd>
            </dl>
        </div>
        <div class="bybuy"><a href="javascript:;"></a></div>

    </div>
</div>
<div class="probox">
	<div class="protitbox clearfix">
    	<a class="x_qing" href="javascript:;">商品介绍</a>
        <a class="c_zizhi" href="javascript:;">产品资质</a>
    </div>
    
    <div class="probox_imgbox">
    <c:if test="${not empty prod.quapics}">
    <c:set value="${fn:split(prod.quapics, '|')}" var="quapic" />
    <c:forEach items="${quapic}" var="s">
		<img src="${svr_url}/${s}"/>
	</c:forEach>
	</c:if>       
    </div>
    <table class="bg_table">
    	<tbody>
        	<tr>
            	<td width="140px;" class="table_bodytit">商品名称</td>
                <td width="820px;">${prod.proName}&nbsp;</td>
            </tr>
        	<tr>
            	<td width="140px;" class="table_bodytit">剂型</td>
                <td width="820px;">${prod.dosageForm }&nbsp;</td>
            </tr>
        	<tr>
            	<td width="140px;" class="table_bodytit">规格</td>
                <td width="820px;">${prod.etalon }</td>
            </tr>
        	<tr>
            	<td width="140px;" class="table_bodytit">供应商</td>
                <td width="820px;">${prod.provider.corporateName}</td>
            </tr>
        	<tr>
            	<td width="140px;" class="table_bodytit">生产企业</td>
                <td width="820px;">${prod.proEnterprise}</td>
            </tr>
            <tr>
            	<td width="140px;" class="table_bodytit">通用名称</td>
                <td width="820px;">${prod.commonName}&nbsp;</td>
            </tr>
        	<tr>
            	<td width="140px;" class="table_bodytit">通用名称编码</td>
                <td width="820px;">${prod.commonCode}&nbsp;</td>
            </tr>
        	<tr>
            	<td width="140px;" class="table_bodytit">是否是处方</td>
                <td width="820px;">${prod.isPrescription}&nbsp;</td>
            </tr>
        	<tr>
            	<td width="140px;" class="table_bodytit">批准文号</td>
                <td width="820px;">${prod.auditingFileNo}&nbsp;</td>
            </tr>
        	<tr>
            	<td width="140px;" class="table_bodytit">说明书</td>
                <td width="820px;">${prod.specification}&nbsp;</td>
            </tr>

        	<tr>
            	<td width="140px;" class="table_bodytit">质量标准</td>
                <td width="820px;">${prod.qualityStandard}&nbsp;</td>
            </tr>
        	<tr>
            	<td width="140px;" class="table_bodytit">装箱规格</td>
                <td width="820px;">${prod.binningEtalon}&nbsp;</td>
            </tr>
        	<tr>
            	<td width="140px;" class="table_bodytit">储存条件</td>
                <td width="820px;">${prod.storageCondition}&nbsp;</td>
            </tr>

        	<tr>
            	<td width="140px;" class="table_bodytit">批件有效期</td>
                <td width="820px;">${prod.approveDate}&nbsp;</td>
            </tr>
            <tr>
            	<td width="140px;" class="table_bodytit">特殊药品类型</td>
                <td width="820px;">${prod.specialDrugsType}&nbsp;</td>
            </tr>
            <tr>
            	<td width="140px;" class="table_bodytit">是否含麻黄碱</td>
                <td width="820px;">${prod.isEphedrine}&nbsp;</td>
            </tr>
            <tr>
            	<td width="140px;" class="table_bodytit">是否是冷藏品</td>
                <td width="820px;">${prod.isColdStorage}&nbsp;</td>
            </tr>
            <tr>
            	<td width="140px;" class="table_bodytit">商品类别</td>
                <td width="820px;">${prod.productionsCategory.name}&nbsp;</td>
            </tr>
        </tbody>
    </table>
</div>

</body>
</html>